package cn.hj.domain.strategy.service.rule.chain.impl;

import cn.hj.domain.strategy.service.Armory.StrategyArmoryDispatch;
import cn.hj.domain.strategy.service.rule.chain.AbstractLogicChain;
import cn.hj.domain.strategy.service.rule.chain.factory.DefaultChainFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 默认责任链
 */
@Component("default")
@Slf4j
public class DefaultLogicChain extends AbstractLogicChain {

    @Resource
    private StrategyArmoryDispatch strategyArmoryDispatch;
    @Override
    public DefaultChainFactory.StrategyAwardVO logic(Long strategyId, String userId) {
        Integer awardId = strategyArmoryDispatch.getRandomAwardId(strategyId);
        log.info("抽奖责任链-默认处理 userId: {} strategyId: {} ruleModel: {} awardId: {}", userId, strategyId, ruleModels(), awardId);
        return DefaultChainFactory.StrategyAwardVO.builder()
                .awardId(awardId)
                .logicModel(ruleModels())
                .build();
    }

    @Override
    protected String ruleModels() {
        return DefaultChainFactory.LogicModel.RULE_DEFAULT.getCode();
    }
}
